package com.chenyaowei.happyhub.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.chenyaowei.happyhub.pojo.GoodsPojo.Good;
import com.chenyaowei.happyhub.service.GoodsService.GoodService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/wechat")
public class WeChatAdController {
    @Resource
    GoodService goodService;
    @RequestMapping("/slidead")
    String slideAd() throws Exception{
        ObjectMapper mapper=new ObjectMapper();
        List<Good> goodList=goodService.selectGoodsBySlideAd();
        String str=mapper.writeValueAsString(goodList);
        return str;
    }
    @RequestMapping("/typead")
    String typeAd(String type) throws Exception{
        ObjectMapper mapper=new ObjectMapper();
        List<Good> goodList=goodService.selectGoodsByTypeAd(type);
        String str=mapper.writeValueAsString(goodList);
        return str;
    }
}
